<?php 
//File ini untuk mengedit record
require_once('lib/dbclass.php');
$db = new MySQL();

// ubah data tabel agenda
$x = $_GET['id'];
if(isset($_POST['ubah'])){	
	
	
	$id_agenda = $_POST['id_agenda'];
	$tema = $_POST['tema'];
	$isi = $_POST['isi'];
	$tempat = $_POST['tempat'];

	if (! $db->Query("UPDATE agenda set id_agenda='$id_agenda',tema='$tema',isi='$isi'
		, tempat='$tempat' 
		WHERE id_agenda='$x'")) $db->Kill(); 

	echo '<script>';
	echo "alert('Success: Anda berhasil merubah agenda');";
	echo "window.location='index.php?q=1'";
	echo '</script>';
}
?>

<?php 
	//Select Data Agenda 
	if(isset($_GET['id'])){		
		if (! $db->Query("SELECT * FROM agenda WHERE id_agenda=$x")) $db->Kill(); 
		if($db->RowCount()>0){
			$rs = $db->RowArray();
		}
	}
?>
	
<h1>Edit Data Contents</h1><br/>
		
		<form class="form-horizontal" role="form" action="" method="post">
			
			<div class="form-group">
				
				<label for="kode" class="col-sm-2 control-label"> Kode   : </label>
				<div class="col-sm-10">
				<input class="form-control" type="text" name="id_agenda" id="id_agenda" value="<?php echo $_SESSION['session_usr'];?>" placeholder="Kode Agenda">
					
			</div>
			</div>

			<div class="form-group">
				
				<label for="tema" class="col-sm-2 control-label">Tema      :</label>
				<div class="col-sm-10">
				<input class="form-control" type="text" name="tema" placeholder="Tema">
				
			</div>
			</div>
			
				<div class="form-group">
					
				<label for="body" class="col-sm-2 control-label">Isi Berita :</label>
				<div class="col-sm-10">
				<textarea class="form-control editor" name="isi" id="isi" rows="12" placeholder="Page Body"><?php echo $rs[4];?></textarea>
				</div>
		    </div>
		   	</div>
			
			<div class="form-group">
					
				<label for="body" class="col-sm-2 control-label"></label>
				<div class="col-sm-10">
					&nbsp;
				</div>
			</div>
			
			<div class="form-group">
   			<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-success">Save</button>
			<input type="hidden" name="ubah" value="Ubah">
			</div>
			</div>
			
		</form>
	